package com.baichang.taoshunda.service.impl;

import com.baichang.taoshunda.dao.TrendsUserDao;
import com.baichang.taoshunda.entity.TrendsUser;
import com.baichang.taoshunda.service.TrendsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by ${wushenglu} on 17/09/20.
 */
@Service
public class TrendsUserServiceImpl implements TrendsUserService {
    @Autowired
    private TrendsUserDao trendsUserDao;

    @Override
    public Long addTrendsUser(Integer userId, int busId) {
        TrendsUser trendsUser = new TrendsUser();
        trendsUser.setUserId(userId);
        trendsUser.setBusId(busId);
        return trendsUserDao.save(trendsUser);
    }

    @Override
    public int getTrendsUserIdByUserId(Integer userId) {

        return trendsUserDao.getTrendsUserIdByUserId(userId);
    }

    /**
     * 根据商家编号查看互动用户编号
     *
     * @param bussId 用户编号
     * @return
     */
    @Override
    public int getTrendsUserIdByBussId(Integer bussId) {
        return trendsUserDao.getTrendsUserIdByBussId(bussId);
    }

    @Override
    public void updateUserInfo(int trendsUserId, String name, String headPic) {
        trendsUserDao.updateTrendsUserInfo(trendsUserId, name, headPic);
        trendsUserDao.updateTrendsReplayUserInfo(trendsUserId, name, headPic);
        trendsUserDao.updateTrendsCommentUserInfo(trendsUserId, name, headPic);
        trendsUserDao.updateTrendsReplayCommentUserInfo(trendsUserId, name);
    }
}
